<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!doctype html>
<html>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8" http-equiv="content-type" content="text/html">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>我的买入</title>
<link href="css/jquery.mobile-1.4.5.min.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/mybuy.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script>
$(document).bind('mobileinit',function(){
 $.mobile.changePage.defaults.changeHash = false;
 $.mobile.hashListeningEnabled = false;
 $.mobile.pushStateEnabled = false;
});
</script>
<script src="js/jquery.mobile-1.4.5.min.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" id="mybuy">
 	<div data-role="content" id="content">
 	</div>
 </div>
</body>
<script type="text/javascript">
var isLast = false;
$(function(){
    setBase();
})
function setBase(){
    getBugThingList(1);
}
//加载本人的闲置列表
function getBugThingList(pageNum){
    if(isLast == false){
        var url = "api/myself/getBugThingList.do";
        $.post(url,{pageNum:pageNum,pageSize:10},
        function(data){
            if(data["STATUS"]=="OK"){
                var resultListJson = eval("("+data["RESULTLIST"]+")");
                var html= '';
                $.each(resultListJson,function(keyDaily,valueDaily){
                    html+='<div class="buy-new">';
                    html+='<div class="goods">';
                    html+='<img src="'+valueDaily.IMGS+'" />';
                    html+='<div class="goods-detail">';
                    html+='<p>'+valueDaily.TITLE+'</p>';
                    html+='<span>'+valueDaily.COST+'</span>';
                    html+='<p class="wait">订单完成</p>';
                    html+='</div>';
                    html+='</div>';
                    html+='<div class="buy-op">';
                    html+='<a href="api/chat/withThing.do?CHATGROUPID='+valueDaily.CHATGROUPID+'">';
                    html+='<img src="images/assess1.png">';
                    html+='<span>联系卖家</span>';
                    html+='</a>';
                    /* html+='<input type="button" value="订单" data-role="none"/>'; */
                    html+='</div>';
                    html+='</div>';
                });
                isLast = data["isLast"];
                $("#content").append(html);
            }
        },'json');
    }
}

//联系买家
function lianxiSeller(thingId){
	$.post("api/chat/newChat.do",
			 {THING_ID:thingId},
			 function(result){
		    	if(result.STATUS=="OK"){
		    		window.location.href="api/chat/withThing.do?CHATGROUPID="+result.GROUPID;
		    	}
		  	},'json');
};
</script>
</html>